package com.cantierinformatici.mygym.data.sqlite;

import com.cantierinformatici.mygym.business.Muscolo;

import android.provider.BaseColumns;

public class Contract {

	public Contract() {
	}
	
	public static final int DB_VERSION = 8;
	public static final String DB_NAME = "my_gym.db";
	private static final String TEXT_TYPE = " TEXT";
	private static final String BOOLEAN_TYPE = " INTEGER";
	private static final String LONG_TYPE = " INTEGER";
	private static final String INT_TYPE = " INTEGER";
	private static final String COMMA_SEP = ",";

	public static final String SQL_CREATE_ESERCIZIO_ENTRIES = 
			"CREATE TABLE " + Contract.EsercizioEntry.TABLE_NAME + " (" +
			Contract.EsercizioEntry._ID + LONG_TYPE + " PRIMARY KEY AUTOINCREMENT" + COMMA_SEP +
			Contract.EsercizioEntry.COLUMN_NAME_NOME + TEXT_TYPE + COMMA_SEP +
			Contract.EsercizioEntry.COLUMN_NAME_ATTREZZO_ID + INT_TYPE + COMMA_SEP +
			Contract.EsercizioEntry.COLUMN_NAME_MUSCOLO_ID + INT_TYPE + COMMA_SEP +
			Contract.EsercizioEntry.COLUMN_NAME_SYNC + BOOLEAN_TYPE + COMMA_SEP +
			Contract.EsercizioEntry.COLUMN_NAME_NOTE + TEXT_TYPE  + 
			" )";	
	public static final String SQL_DELETE_ESERCIZIO_ENTRIES = 
			"DROP TABLE IF EXISTS " + Contract.EsercizioEntry.TABLE_NAME;
			
	public static final String SQL_CREATE_ATTREZZO_ENTRIES = 
			"CREATE TABLE " + Contract.AttrezzoEntry.TABLE_NAME + " (" +
			Contract.AttrezzoEntry._ID + LONG_TYPE + " PRIMARY KEY AUTOINCREMENT" + COMMA_SEP +
			Contract.AttrezzoEntry.COLUMN_NAME_NOME + TEXT_TYPE + COMMA_SEP +
			Contract.AttrezzoEntry.COLUMN_NAME_SYNC + BOOLEAN_TYPE + COMMA_SEP +
			Contract.AttrezzoEntry.COLUMN_NAME_FOTO + TEXT_TYPE  +
			" )";
	public static final String SQL_DELETE_ATTREZZO_ENTRIES = 
			"DROP TABLE IF EXISTS " + Contract.AttrezzoEntry.TABLE_NAME;		
	
	public static final String SQL_CREATE_MUSCOLO_ENTRIES = 
			"CREATE TABLE " + Contract.MuscoloEntry.TABLE_NAME + " (" +
			Contract.MuscoloEntry._ID + LONG_TYPE + " PRIMARY KEY AUTOINCREMENT" + COMMA_SEP +
			Contract.MuscoloEntry.COLUMN_NAME_NOME + TEXT_TYPE + COMMA_SEP +
			Contract.MuscoloEntry.COLUMN_NAME_FOTO + TEXT_TYPE + COMMA_SEP +
			Contract.MuscoloEntry.COLUMN_NAME_SYNC + BOOLEAN_TYPE +
			" )";
	public static final String SQL_DELETE_MUSCOLO_ENTRIES = 
			"DROP TABLE IF EXISTS " + Contract.MuscoloEntry.TABLE_NAME;	
	
	public static final String SQL_CREATE_ATTIVITA_ENTRIES = 
			"CREATE TABLE " + Contract.AttivitaEntry.TABLE_NAME + " (" +
			Contract.AttivitaEntry._ID + LONG_TYPE + " PRIMARY KEY AUTOINCREMENT" + COMMA_SEP +
			Contract.AttivitaEntry.COLUMN_NAME_DATE + TEXT_TYPE + COMMA_SEP +
			Contract.AttivitaEntry.COLUMN_NAME_SYNC + BOOLEAN_TYPE + COMMA_SEP +
			Contract.AttivitaEntry.COLUMN_NAME_NOTE + TEXT_TYPE +
			" )";
	public static final String SQL_DELETE_ATTIVITA_ENTRIES = 
			"DROP TABLE IF EXISTS " + Contract.AttivitaEntry.TABLE_NAME;
	
	public static final String SQL_CREATE_SERIE_ENTRIES = 
			"CREATE TABLE " + Contract.SerieEntry.TABLE_NAME + " (" +
			Contract.SerieEntry._ID + LONG_TYPE + " PRIMARY KEY AUTOINCREMENT" + COMMA_SEP +
			Contract.SerieEntry.COLUMN_NAME_RIPETITIONS + INT_TYPE + COMMA_SEP +
			Contract.SerieEntry.COLUMN_NAME_SYNC + BOOLEAN_TYPE + COMMA_SEP +
			Contract.SerieEntry.COLUMN_NAME_ATTIVITA_ID + INT_TYPE + COMMA_SEP +
			Contract.SerieEntry.COLUMN_NAME_WEIGHT + INT_TYPE +
			" )";
	public static final String SQL_DELETE_SERIE_ENTRIES = 
			"DROP TABLE IF EXISTS " + Contract.SerieEntry.TABLE_NAME;				
	
	public static final String SQL_CREATE_PESO_ENTRIES = 
			"CREATE TABLE " + Contract.PesoCorporeoEntry.TABLE_NAME + " (" +
			Contract.PesoCorporeoEntry._ID + LONG_TYPE + " PRIMARY KEY AUTOINCREMENT" + COMMA_SEP +
			Contract.PesoCorporeoEntry.COLUMN_NAME_DATE + TEXT_TYPE + COMMA_SEP +
			Contract.PesoCorporeoEntry.COLUMN_NAME_SYNC + BOOLEAN_TYPE + COMMA_SEP +
			Contract.PesoCorporeoEntry.COLUMN_NAME_WEIGHT + INT_TYPE +
			" )";
	public static final String SQL_DELETE_PESO_ENTRIES = 
			"DROP TABLE IF EXISTS " + Contract.PesoCorporeoEntry.TABLE_NAME;

	public static class EsercizioEntry implements BaseColumns {

		public static final String TABLE_NAME = "Esercizio";

		public static final String COLUMN_NAME_NOME = "nome_esercizio";

		public static final String COLUMN_NAME_NOTE = "nota_esercizio";

		public static final String COLUMN_NAME_ATTREZZO_ID = "attrezzo_id";

		public static final String COLUMN_NAME_MUSCOLO_ID = "muscolo_id";

		public static final String COLUMN_NAME_SYNC = "sync_esercizio";

		public static final String[] COLUMNS_PROJECTION;
		
		public static final String[] COLUMNS_PROJECTION_MULTI;

		static {
			COLUMNS_PROJECTION = new String[] { _ID, COLUMN_NAME_NOME,COLUMN_NAME_ATTREZZO_ID,COLUMN_NAME_MUSCOLO_ID };
		}
		
		static {
			COLUMNS_PROJECTION_MULTI = new String[] { _ID, COLUMN_NAME_NOME,AttrezzoEntry.COLUMN_NAME_NOME,MuscoloEntry.COLUMN_NAME_NOME,COLUMN_NAME_ATTREZZO_ID,COLUMN_NAME_MUSCOLO_ID };
		}

	}

	public static class AttrezzoEntry implements BaseColumns {

		public static final String TABLE_NAME = "Attrezzo";

		public static final String COLUMN_NAME_NOME = "nome_attrezzo";

		public static final String COLUMN_NAME_FOTO = "foto_attrezzo";

		public static final String COLUMN_NAME_SYNC = "sync_attrezzo";

		public static final String[] COLUMNS_PROJECTION;

		static {
			COLUMNS_PROJECTION = new String[] { _ID, COLUMN_NAME_NOME };
		}

	}

	public static class MuscoloEntry implements BaseColumns {

		public static final String TABLE_NAME = "Muscolo";

		public static final String COLUMN_NAME_NOME = "nome_muscolo";

		public static final String COLUMN_NAME_FOTO = "foto_muscolo";

		public static final String COLUMN_NAME_SYNC = "sync_muscolo";
		
		public static final String[]  COLUMNS_PROJECTION;

		static {
			COLUMNS_PROJECTION = new String[] { _ID, COLUMN_NAME_NOME };
		}
	}

	public static class AttivitaEntry implements BaseColumns {

		public static final String TABLE_NAME = "Esercizio_Svolto";

		public static final String COLUMN_NAME_DATE = "data_esercizio_svolto";

		public static final String COLUMN_NAME_NOTE = "nota_esercizio_svolto";

		public static final String COLUMN_NAME_SYNC = "sync_esercizio_svolto";

		public static final String COLUMN_NAME_ESERCIZIO_ID = "esercizio_id";
		
		public static final String[] COLUMNS_PROJECTION;

		static {
			COLUMNS_PROJECTION = new String[] { _ID, COLUMN_NAME_DATE,COLUMN_NAME_NOTE };
		}
	}

	public static class SerieEntry implements BaseColumns {

		public static final String TABLE_NAME = "Serie";

		public static final String COLUMN_NAME_RIPETITIONS = "numero_ripetizioni_serie";

		public static final String COLUMN_NAME_WEIGHT = "peso_serie";
		
		public static final String COLUMN_WEIGHT_FACTOR = "peso_fattore";

		public static final String COLUMN_NAME_SYNC = "sync_serie";

		public static final String COLUMN_NAME_ATTIVITA_ID = "esercizio_svolto_id";
		
		public static final String[] COLUMNS_PROJECTION;

		static {
			COLUMNS_PROJECTION = new String[] { _ID, COLUMN_NAME_RIPETITIONS,COLUMN_NAME_WEIGHT,COLUMN_WEIGHT_FACTOR };
		}

	}

	public static class PesoCorporeoEntry implements BaseColumns {

		public static final String TABLE_NAME = "Peso_Corporeo";

		public static final String COLUMN_NAME_WEIGHT = "peso_corporeo";

		public static final String COLUMN_NAME_DATE = "data_peso_corporeo";

		public static final String COULMN_NAME_NOTE = "nota_peso_corporeo";

		public static final String COLUMN_NAME_SYNC = "sync_peso_corporeo";
		
		public static final String[] COLUMNS_PROJECTION;

		static {
			COLUMNS_PROJECTION = new String[] { _ID, COLUMN_NAME_DATE,COLUMN_NAME_WEIGHT };
		}
	}

	public static class FotoEntry implements BaseColumns {

		public static final String TABLE_NAME = "Foto";

		public static final String COLUMN_NAME_FOTO = "foto";

		public static final String COLUMN_NAME_DATE = "data_foto";

		public static final String COLUMN_NAME_SYNC = "sync_foto";

		public static final String COLUMN_NAME_TIPO = "tipo_foto";

		public static final String COLUMN_NAME_ID_PADRE = "padre_id";
		
		public static final String[] COLUMNS_PROJECTION;

		static {
			COLUMNS_PROJECTION = new String[] { _ID, COLUMN_NAME_DATE,COLUMN_NAME_FOTO };
		}
	}

}
